CSharpTest.Net
Clone Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Collections Namespace > SetList<T> Class : Clone Method

Glossary Item Box

Returns a shallow clone of this object

Syntax

Visual Basic (Declaration) 
Public Function Clone() As SetList(Of T)
C# 
public SetList<T> Clone()

Example

Library/Library.Test/TestSetList.cs

C#Copy Code
SetList<int> lista = new SetList<int>(new int[] { 5, 10, 20 });
SetList<int> listb = new SetList<int>(new int[] { 2, 4, 6, 8, 10 });

SetList<int>subt = lista.SubtractSet(listb);
Assert.IsFalse(subt.IsEqualTo(lista));
Assert.IsTrue(subt.Contains(5));
Assert.IsFalse(subt.Contains(10));
Assert.IsTrue(subt.IsEqualTo(new SetList<int>(new int[] { 5, 20 })));

Assert.IsTrue(subt.IsSubsetOf(lista));
Assert.IsFalse(subt.IsSupersetOf(lista));

Assert.IsTrue(lista.IsSupersetOf(subt));
Assert.IsFalse(lista.IsSubsetOf(subt));
            
SetList<int> copy = lista.Clone();
copy.RemoveAll(listb);
Assert.IsFalse(copy.IsEqualTo(lista));
Assert.IsTrue(copy.IsEqualTo(subt));

copy.Add(11);
Assert.IsFalse(copy.IsEqualTo(lista));

SetList<int> xor = lista.ExclusiveOrWith(listb);
Assert.IsTrue(xor.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8, 5, 20 })));

SetList<int> comp = lista.ComplementOf(listb);
Assert.IsTrue(comp.IsEqualTo(new SetList<int>(new int[] { 2, 4, 6, 8 })));
VB.NETCopy Code
Dim lista As New SetList(Of Integer)(New Integer() {5, 10, 20})
Dim listb As New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 10})

Dim subt As SetList(Of Integer) = lista.SubtractSet(listb)
Assert.IsFalse(subt.IsEqualTo(lista))
Assert.IsTrue(subt.Contains(5))
Assert.IsFalse(subt.Contains(10))
Assert.IsTrue(subt.IsEqualTo(New SetList(Of Integer)(New Integer() {5, 20})))

Assert.IsTrue(subt.IsSubsetOf(lista))
Assert.IsFalse(subt.IsSupersetOf(lista))

Assert.IsTrue(lista.IsSupersetOf(subt))
Assert.IsFalse(lista.IsSubsetOf(subt))

Dim copy As SetList(Of Integer) = lista.Clone()
copy.RemoveAll(listb)
Assert.IsFalse(copy.IsEqualTo(lista))
Assert.IsTrue(copy.IsEqualTo(subt))

copy.Add(11)
Assert.IsFalse(copy.IsEqualTo(lista))

Dim [xor] As SetList(Of Integer) = lista.ExclusiveOrWith(listb)
Assert.IsTrue([xor].IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8, 5, 20})))

Dim comp As SetList(Of Integer) = lista.ComplementOf(listb)
Assert.IsTrue(comp.IsEqualTo(New SetList(Of Integer)(New Integer() {2, 4, 6, 8})))

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys